home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
dev
/
lang
/
ace102.lha
/
include
/
inputs.h
< prev
next >
Wrap
Text File
|
1993-01-30
|
2KB
|
151 lines
{ ** Get INPUT from the current SCREEN **
INPUTS$ - input a string.
INPUTS% - input a short integer.
INPUTS& - input a long integer.
INPUTS! - input a single-precision value.
Author: David J Benn
Date: 8th,14th July 1992,
1st January 1993
}
SUB cursor
oldfg%=window(10)
color window(6),0
prints "|";
locate csrlin,pos-1
color oldfg%,0
END SUB
SUB inputs$
shortint ccol
const MAXCOL=80
'..start column
ccol=pos
cursor
'..input a string.
z$=""
repeat
'..await a keystroke
repeat
x$=inkey$
until x$<>""
'..if printable, print it.
if asc(x$) >= 32 and pos < MAXCOL then
z$=z$+x$
prints x$;
cursor
else
'..BS or DEL?
if asc(x$)=8 and pos > ccol then
'..erase cursor and character
locate csrlin,pos-1
prints " ";
locate csrlin,pos-2
cursor
'..chop off right-most character
z$=left$(z$,len(z$)-1)
end if
end if
until x$=chr$(13)
'..erase cursor
prints " "
'..return string
inputs$=z$
END SUB
SUB spacestripped$(x$)
shortint l,i,s
'..strip ALL whitespace from x$
'..(VAL does this too).
y$=""
i=1
l=len(x$)
while i<=l
s$=mid$(x$,i,1)
if s$ > " " then y$=y$+s$
++i
wend
spacestripped$ = y$
END SUB
SUB inputs%
shortint l,i,s,sign
num$ = inputs$
num$ = spacestripped$(num$)
'..leading + or - ?
first$=mid$(num$,1,1)
if first$="-" or first$="+" then
case
first$="-" : sign = -1
first$="+" : sign = 1
end case
num$=right$(num$,len(num$)-1)
else
sign=1
end if
'..get value
i=1
l=len(num$)
num%=0
repeat
s=asc(mid$(num$,i,1))
num% = num%*10 + s-asc("0")
++i
until i>l or s<asc("0") or s>asc("9")
inputs% = num%*sign
END SUB
SUB inputs&
shortint l,i,s,sign
num$ = inputs$
num$ = spacestripped$(num$)
'..leading + or - ?
first$=mid$(num$,1,1)
if first$="-" or first$="+" then
case
first$="-" : sign = -1
first$="+" : sign = 1
end case
num$=right$(num$,len(num$)-1)
else
sign=1
end if
'..get value
i=1
l=len(num$)
num&=0
repeat
s=asc(mid$(num$,i,1))
num& = num&*10& + s-asc("0")
++i
until i>l or s<asc("0") or s>asc("9")
inputs& = num&*sign
END SUB
SUB inputs!
inputs!=val(inputs$)
END SUB